#include "../sc_defines.h"
#include "../../../../game/Player.h"
#include "../../../../game/GameObject.h"
#include "../../../../game/GossipDef.h"
#include "../../../../game/QuestDef.h"
#include "../../../../game/World.h"

bool GossipHello_Attack_City(Player *player, Creature *_Creature)
{
	if(!player->isInCombat())
	{
	player->ADD_GOSSIP_ITEM( 4, " 攻城系统 " , 1, GOSSIP_ACTION_INFO_DEF + 1);
	player->ADD_GOSSIP_ITEM( 4, " 申请攻城 " , 1, GOSSIP_ACTION_INFO_DEF + 2);
	player->ADD_GOSSIP_ITEM( 4, " 招募下级剑士 " , 1, GOSSIP_ACTION_INFO_DEF + 3);
	player->ADD_GOSSIP_ITEM( 4, " 招募中级剑士 " , 1, GOSSIP_ACTION_INFO_DEF + 4);
	player->ADD_GOSSIP_ITEM( 4, " 招募高级剑士 " , 1, GOSSIP_ACTION_INFO_DEF + 5);
	player->ADD_GOSSIP_ITEM( 4, " 招募近战英雄 " , 1, GOSSIP_ACTION_INFO_DEF + 6);
	player->ADD_GOSSIP_ITEM( 4, " 招募远程英雄 " , 1, GOSSIP_ACTION_INFO_DEF + 7);
	player->ADD_GOSSIP_ITEM( 4, " 攻城结束，申请城主 " , 1, GOSSIP_ACTION_INFO_DEF + 8);
	player->SEND_GOSSIP_MENU(99990,_Creature->GetGUID());
	return true;
	}
	else if(player->isInCombat())//是城主
	{
	player->ADD_GOSSIP_ITEM( 4, " 领取金币 " , 1, GOSSIP_ACTION_INFO_DEF + 9);
	return true;
	}
	else 
		return false;
}

void SendDefaultMenu_Attack_City(Player *player, Creature *_Creature, uint32 action)
{
	switch(action){
case GOSSIP_ACTION_INFO_DEF + 1 :
	   //攻城系统
	player->SEND_GOSSIP_MENU(99991,_Creature->GetGUID());
	break;
case GOSSIP_ACTION_INFO_DEF + 2 :
	// 申请攻城(需要1000G)	//开始	//世界通知	//倒计时	//变阵营	//刷怪
	 uint32 price;
	 price=100*10000;
	 if (player->GetMoney() >= price)
		{
		 //std::string str = "|cffff0000|Attack start";
		 //sWorld.SendWorldText(str.c_str()); //世界通知
		 player->ModifyMoney(-int32(price)); //召唤四大守城卫士
         player->SummonCreature(15691,player->GetPositionX() ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,3600000);
         player->SummonCreature(17547,player->GetPositionX()+5 ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,3600000);
         player->SummonCreature(15688,player->GetPositionX()+15 ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,3600000);
         player->SummonCreature(17546,player->GetPositionX()+15 ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,3600000);
		}
	else
		 player->GetSession()->SendAreaTriggerMessage("对不起你的钱不够");
         GossipHello_Attack_City(player,_Creature);
		 break;
case GOSSIP_ACTION_INFO_DEF + 3 :
    //招募下级剑士
	//刷怪。怪移动
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;

case GOSSIP_ACTION_INFO_DEF + 4 :
    //招募中级剑士
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;

case GOSSIP_ACTION_INFO_DEF + 5 :
    //招募高级剑士
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;

case GOSSIP_ACTION_INFO_DEF + 6 :
    //招募近战英雄
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;

case GOSSIP_ACTION_INFO_DEF + 7 :
    //招募远程英雄
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;
case GOSSIP_ACTION_INFO_DEF + 8 :
    //申请城主
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;
case GOSSIP_ACTION_INFO_DEF + 9 :
    //领取金币
	player->SEND_GOSSIP_MENU(99993,_Creature->GetGUID());
	break;
	}
}

void AddSC_Attack_City()
{
	Script *newscript;

	newscript = new Script;
    newscript->Name="attack_city";
    newscript->pGossipHello          = &GossipHello_Attack_City;
    //newscript->GetAI = GetAI_Attack_City;
    m_scripts[nrscripts++] = newscript;

}
